<%@ page import="com.devicemantra.coordinate.dataobjects.*,java.util.*,com.google.appengine.api.datastore.KeyFactory" %>
<%
	
String lCategoryRequested = request.getParameter("category");
System.out.println("getWindow.jsp called now category " + lCategoryRequested + "!!!");
Thread.sleep(500);
if( lCategoryRequested.equals("state"))
{
	out.println("<form name=\"add_state\" action=\"AddState\" method=\"POST\"> " + 
	"<INPUT TYPE = text name=\"state_name\">" + 
	"<INPUT TYPE = SUBMIT VALUE=\"Add State\"> ");

	List<CState> lListOfStates = (List<CState>) CStateFactory.getAllStates();
	Iterator<CState> lStateIter = lListOfStates.iterator();
	out.print("<TABLE BORDER=1 COLOR=00FF00>");
		
	int counter = 3;
	while( lStateIter.hasNext())
	{
		 if( (counter % 3 ) == 0) 
		 {
			 	out.print("<TR>");
			 	
		 }
			 counter++;
			 CState lState = lStateIter.next();
			 out.print("<TD>" + lState.getName() +  "</TD>");
			 
			 if( (counter % 3 ) == 0)
			 {
			 	out.print("</TR>");
			 }
			 
	}
		out.print("</TABLE>");
		out.println("</form>");
}
else if( lCategoryRequested.equals("department"))
{
	out.println("<form name=\"add_department\" action=\"AddDepartment\" method=\"POST\">" + 
	"<INPUT TYPE = text name=\"dept_name\">" + 
	"<INPUT TYPE = SUBMIT VALUE=\"Add Department\">" + 
	"</form>");

	List<CDepartment> lListOfDepts = (List<CDepartment>) CDepartmentFactory.getAllDepartments();
	Iterator<CDepartment> lDepartmentIter = lListOfDepts.iterator();
	out.print("<TABLE BORDER=1 COLOR=00FF00>");
		
	int counter = 3;
	while( lDepartmentIter.hasNext())
	{
		 if( (counter % 3 ) == 0) 
		 {
			 	out.print("<TR>");
			 	
		 }
			 counter++;
			 CDepartment lDept = lDepartmentIter.next();
			 out.print("<TD>" + lDept.getDepartmentName() +  "</TD>");
			 
			 if( (counter % 3 ) == 0)
			 {
			 	out.print("</TR>");
			 }
			 
	}
		out.print("</TABLE>");
		out.println("</form>");
}
else if(lCategoryRequested.equals("subdepartment"))
{
	String lDepartment = request.getParameter("department");
	List<SubDepartment> lListOfSubDepts = SubDepartmentFactory.getAllSubDepartments(lDepartment);
	Iterator<SubDepartment> lSubDepartmentIter = lListOfSubDepts.iterator();
	out.print("<TABLE BORDER=1 COLOR=00FF00>");
	System.out.println("getWindow.jsp called now with dept = " + lDepartment);	
	int counter = 3;
	while( lSubDepartmentIter.hasNext())
	{
		 if( (counter % 3 ) == 0) 
		 {
			 	out.print("<TR>");
			 	
		 }
			 counter++;
			 SubDepartment lSubDept = lSubDepartmentIter.next();
			 out.print("<TD><input type=\"checkbox\" name=\"vehicle\" value=\"Car\" DISABLED />" + lSubDept.getSubDepartmentName() +  "</TD>");
			 
			 if( (counter % 3 ) == 0)
			 {
			 	out.print("</TR>");
			 } 
			 
	}
		out.print("<TR>" + "<div id=\"temp\">" + "</div>" +  "</TR>" );
		out.print("</TABLE><br><br>");
}


	
%>
